﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace UdpPeer.Assets
{
    /// <summary>
    /// 邦定指令进行执行.
    /// </summary>
    public class CommandInput : System.Windows.Input.ICommand
    {
        /// <summary>
        /// 执行指令动作
        /// </summary>
        public Action<object> ExecuteAction { get; set; }
        public bool CanExecute(object parameter)
        {
            return true;
        }

        public event EventHandler CanExecuteChanged;

        public void Execute(object parameter)
        {
            if (ExecuteAction != null)
            {
                ExecuteAction(parameter);
            }
            if (CanExecuteChanged != null)
            {
                CanExecuteChanged(this, EventArgs.Empty);
            }
        }

    }
}
